package com.vxb.testmvp.test_jsmap;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.vxb.testmvp.R;

public class TestJsMapActivity extends AppCompatActivity {

    private WebView mWebView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test_js_map);

        mWebView = (WebView) findViewById(R.id.webView);

        initWebViewSetting();

        mWebView.loadUrl("file:///android_asset/amap.html");




        mWebView.setWebViewClient(new WebViewClient() {
            @Override
            public void onPageFinished(WebView view, String url) {
                //调用JS方法，将商家坐标设置到地图上
                mWebView.loadUrl("javascript:addMarker(" +  120.380028 + "," + 36.093914 + ")");
            }
        });


    }

    private void initWebViewSetting() {
        mWebView.getSettings().setJavaScriptEnabled(true);

    }
}
